
package msu.ml.data.level2;

import java.io.*;

/**
 * @author Reginald M Mead
 * @version 1.0
 *
 * The Packet class represents a packet
 * of Nexrad Level II data.
 *
 */
public class RadialDataBlock 
{
   public RadialDataBlock(Level2InputStream stream)
   {
      name = new char[3];

      if(stream != null)
      {
         try
         {
            type = (char)stream.readByte();
            stream.readBytes(name, 0, 3);
            size = stream.readShort();
            unambiguousRange = stream.readShort();
            hNoise = stream.readFloat();
            vNoise = stream.readFloat();
            nyquistVelocity = stream.readShort();
            stream.skip(2);
         }
         catch(IOException e)
         {
            System.out.println("RadialDataBlock Error: " + e.getMessage());
            e.printStackTrace();
         }
      }
   }

   private static String formatString = "\nName: %1$c%2$s\nSize: %3$d\nUnambiguous Range: %4$d\nHorizontal Noise: %5$.2f\nVertical Noise: %6$.2f\nNyquist Velocity: %7$d";

   public String toString()
   {
      return String.format(RadialDataBlock.formatString, type, 
         new String(name), size, unambiguousRange, hNoise, 
         vNoise, nyquistVelocity);
   }
   
   public char type;
   public char [] name;
   public short size;
   public short unambiguousRange;
   public float hNoise;
   public float vNoise;
   public short nyquistVelocity;
}
